<?php
#[Table('role')]
#[PrimaryKey('id')]
class Areas_Auth_Models_Roles extends XPHP_Model
{
    public $id;
    
    public $name;
    
    public $title;
    
    public $description;
    
    /**
     * Phương thức lấy ra toàn bộ roles của user
     * @param int $userId
     */
    public function getRoles($userId)
    {
        $roles = $this->db->select('role.*')
                           ->join('user_role', 'user_role.role_id = role.id')
                           ->where('user_role.user_id', $userId)
                           ->where('user_role.active', 1)
                           ->get()
                           ->result();
        return $roles;
    }
}